package com.study.gank.ui.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.study.gank.bean.GankGoods
import com.study.gank.databinding.ItemGankGoodsBinding

class GankGoodsAdapter(private val mDatas: List<GankGoods>) :
    BaseBindingAdapter<ItemGankGoodsBinding>() {
    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): DataBindViewHolder<ItemGankGoodsBinding> {
        return DataBindViewHolder(
            ItemGankGoodsBinding.inflate(
                LayoutInflater.from(parent.context),
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(holder: DataBindViewHolder<ItemGankGoodsBinding>, position: Int) {
        super.onBindViewHolder(holder, position)
        holder.binding.gankGoods = mDatas[position]
        holder.binding.executePendingBindings()
    }

    override fun getItemCount() = mDatas.size
}